﻿using System;
using System.Collections.Generic;
using System.Data.Objects.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZBJF.Warranty.Common.Common;
using ZBJF.Warranty.Common.Enums.InsuranceOrder;
using ZBJF.Warranty.Common.Enums.InsuranceWarranty;
using ZBJF.Warranty.Model;
using ZBJF.Warranty.Model.ViewModel.Udesk;

namespace ZBJF.Warranty.BLL
{
    public partial class Udesk_CustomerInfoService
    {
        public IQueryable<Udesk_CustomerInfo> GetPagingList(CustomerInfoModel model, out int total)
        {
            var expressionWhere = PredicateExtensions.True<Udesk_CustomerInfo>();
            if (!string.IsNullOrEmpty(model.Nick_name))
            {
              expressionWhere =expressionWhere.And(n => n.Nick_name.Contains(model.Nick_name));
            }
            if (!string.IsNullOrEmpty(model.Email))
            {
             expressionWhere= expressionWhere.And(n => n.Email.Contains(model.Email));
            }
            if (!string.IsNullOrEmpty(model.Cellphones))
            {
                expressionWhere = expressionWhere.And(n => n.Cellphones.Contains(model.Cellphones));
            }
            if (model.UdeskID.HasValue)
            {
                expressionWhere = expressionWhere.And(n => n.UdeskID.Equals(model.UdeskID.Value));
            }
            if (!string.IsNullOrEmpty(model.Cellphones))
            {
                expressionWhere = expressionWhere.And(n => n.Cellphones.Contains(model.Cellphones));
            }
            if (string.IsNullOrEmpty(model.iSorts))
            {
                model.iSorts = "ID desc";
            }
            return LoadPagerEntities<Udesk_CustomerInfo>(model.PageIndex, model.iDisplayLength, out total, expressionWhere, model.iSorts);

        }
    }
}
